<template>
  <van-nav-bar
      fixed
      title="账户信息"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
  />
  <van-divider></van-divider>
  <van-divider></van-divider>
  <van-form @submit="onSubmit">
    <van-field
        v-model="real_name"
        name="真实姓名"
        label="真实姓名"
        placeholder="真实姓名"
        :rules="[{ required: true, message: '请填写真实姓名' }]"
    />
    <van-field
        v-model="alipay_account"
        name="支付宝账号"
        label="支付宝账号"
        placeholder="支付宝账号"
        :rules="[{ required: true, message: '请填写支付宝账号' }]"
    />
    <div style="margin: 16px;">
      <van-button round block type="primary" native-type="submit">
        提交
      </van-button>
    </div>
  </van-form>
</template>

<script>
import {user,updateAlipay} from "@/api/user";
import {Toast} from "vant";

export default {
  name: "wallet",
  data(){
    return {
      real_name:"",
      alipay_account:""
    }
  },
  created() {
    user().then((res)=>{
      console.log(res)
      this.real_name = res.real_name
      this.alipay_account = res.alipay_account
    })
  },
  methods: {
    onClickLeft() {
      history.back()
    },
    onSubmit(){
      updateAlipay(this.real_name,this.alipay_account).then((res)=>{
        console.log(res)
        Toast.success("操作成功")
      })
    }
  }
}
</script>

<style scoped>

</style>
